/* This file represents the interface for the server of the named
 * pipes. */

#ifndef  _HLIB_LPS_IFACE
#define  _HLIB_LPS_IFACE

#include <stdint.h>
#include <stddef.h>

enum hlib_lps_ret{
  hlib_lps_ok=0,
  hlib_lps_mem_error=1
};

enum hlib_lps_con_type {
  hlib_lps_one_way=0,
  hlib_lps_two_way=1
};

struct hlib_lps_pair_end {
  void * data;
  enum hlib_lps_con_type con_type;
};

struct hlib_lps_channel {
  struct hlib_lps_pair_end * data;
  
  void * buffer_in_arr;
  void * buffer_out_arr;
  
  // AF_UNIX SOCKET FOR UNIX
  void * control_data;

  const char * channel_name;
  uint32_t hard_endpoint_count;
  
  size_t buffer_in_size;
  size_t buffer_out_size;
};

struct _hlib_lps_global_state {
  struct hlib_lps_channel * channel_data;
  uint32_t active_channel_count;
  uint32_t hard_channel_limit;
  const char * base_name;// this + channel name = absolute name;
  const char * func_profile_name;
};

struct hlib_channel_handle {
  uint32_t data;
};


/* Function to initialize the functions of this interface */
enum hlib_lps_ret hlib_lps_init();

struct _hlib_lps_functions {
  enum hlib_lps_ret (* init_server) 
      (const char * base_name,
       uint32_t hard_channel_limit);

  enum hlib_lps_ret (* create_channel)
      (struct hlib_channel_handle * channel_handle,
       const char * channel_name,
       uint32_t endpoint_count,
       size_t buffer_in_size,
       size_t buffer_out_size);
};

extern struct _hlib_lps_functions    hlib_lps_functions;
extern struct _hlib_lps_global_state hlib_lps_global_state;

#endif // _HLIB_LPS_IFACE
